package com.jetbrains.licenseService.util;


import java.math.BigInteger;
import java.security.*;
import java.security.spec.RSAPublicKeySpec;


public class PublicKeys {
    public static BigInteger LICENSE_PUBLIC_MODULUS = new BigInteger("a271e90269adfca29a325bfd6a8598f6c4d0bdad01dcd870771c9ca0b6bbafb556865ffc6a29e1b08ff653fbe21c5c9bea2bf7fefc524a3961b50d800d100c73", 16);
    public static BigInteger LICENSE_PUBLIC_EXPONENT = new BigInteger("10001", 16);
    public static final PublicKey SIGNATURE_PUBLIC_KEY;
    public static final BigInteger ENCRYPTION_MODULUS = new BigInteger("9abc18b618c2fd96ccc6659f8287a2400c728089447e9175f190994715da826a2d3d8913a4f63f646ef8bfb080e77629713cf1446141974368c2cccbaa1f7325", 16);
    public static final BigInteger ENCRYPTION_EXPONENT = new BigInteger("10001", 16);
    public static final String SIG_START = "<!-- ";
    public static final String SIG_END = " -->";
    public static final PublicKey SERVER_CERT_SIGNATURE_PUBLIC_KEY;
    public static final BigInteger SERVER_CERT_ENCRYPTION_MODULUS = new BigInteger("ccf084da03e02840a8e42077053030e17aeb36983e6304cccde34d0d8b3855d3f306ad2c9d6b1b9b9a8feb3d46046513af86a0111414c5ce3ffe064c474509f3d19654d60f6d9fccae47f268e89e9bcc68b2e67eed6a05bb89d89ca6c104c040ed2da276b3d298fbf6c1888724263b78dd807558a2152014786c3fee9220a2ef76ff805b9ba492cd104a0587d121fc2ad198044d222384d479a375c90798b60a44a3324ee436231605aabe025bfe526ff13059e5e638aaf47ed80002e01ff9991ebf00367892c81c248f8affec6437508630a0bac6c52392118f54844a5da909116d24a3422158325858100b4b1112b829939b4ee52076213a5a4dfc10e299c32d5e13f10887cbd60471521f9a293d22b87726a6c63f68e5cda0d61274ed9054095fe7b2b29bfabb8c93005f236f3af873d33149a82ae51f49f1d9e538ae17912f7120fb0dfd99085a51ba03ecdba1511afb6c8813049aee2ee9fbb944d921b3b51eaba2126e5b7a763ff2a2ecb0880667cabb4d2895722b49b4e7583d6f62289078eb93d5d3b304ea0470e364a62b606ff98c3492cef47fa6d47d608ac71746bd03a2d02d9e9ec2ce0550ee8efd186261757c160803ed9520d35f4e054c77ac5d4bdc605803c62160ffcdd7cafc0ea39a160522443c9e44c6e46bd3976762894fa88bfa639f83fb2f496f257382f212073227db24ecc470ae1969dca7345bb5", 16);
    public static final BigInteger SERVER_CERT_ENCRYPTION_EXPONENT = new BigInteger("10001", 16);

    static {
        try {
            KeyFactory localKeyFactory = KeyFactory.getInstance("RSA");
            SIGNATURE_PUBLIC_KEY = localKeyFactory.generatePublic(new RSAPublicKeySpec(ENCRYPTION_MODULUS, ENCRYPTION_EXPONENT));
            SERVER_CERT_SIGNATURE_PUBLIC_KEY = localKeyFactory.generatePublic(new RSAPublicKeySpec(SERVER_CERT_ENCRYPTION_MODULUS, SERVER_CERT_ENCRYPTION_EXPONENT));
        } catch (Exception localException) {
            throw new RuntimeException(localException);
        }
    }

    public static Signature createVerifyingSignature()
            throws NoSuchAlgorithmException, InvalidKeyException {
        Signature localSignature = Signature.getInstance("MD5withRSA");
        localSignature.initVerify(SIGNATURE_PUBLIC_KEY);
        return localSignature;
    }
}
